﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 转介申请信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_APP_REFREGINFO: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_APP_REFREGINFO()
		{}
		#region Model
		private long _id;
		private long _reginfoid;
		private string _custname;
		private string _refby;
		private string _refbyname;
		private Nullable<DateTime> _appdate;
		private long _outdepid;
		private string _outdepname;
		private Nullable<DateTime> _outtime;
		private long _indepid;
		private string _indepname;
		private Nullable<DateTime> _intime;
		private long _salesmanid;
		private string _salesman;
		private string _detail;
		private int _status;
		private string _auditby;
		private Nullable<DateTime> _audittime;
		private int _backstatus;
		private int _sparefield1;
		private string _sparefield2;
		private string _sparefield3;
		/// <summary>
		/// 主键ID主键ID，唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 申请登记记录ID
		/// </summary>
		[DataMember]
		public long REGINFOID
		{
			get{return _reginfoid;}
			set{
				if ( _reginfoid!= value)
				{
					 _reginfoid = value;
					OnPropertyChanged("REGINFOID");
				}
			}
		}
		/// <summary>
		/// 客户名称
		/// </summary>
		[DataMember]
		public string CUSTNAME
		{
			get{return _custname;}
			set{
				if ( _custname!= value)
				{
					 _custname = value;
					OnPropertyChanged("CUSTNAME");
				}
			}
		}
		/// <summary>
		/// 转介人
		/// </summary>
		[DataMember]
		public string REFBY
		{
			get{return _refby;}
			set{
				if ( _refby!= value)
				{
					 _refby = value;
					OnPropertyChanged("REFBY");
				}
			}
		}
		/// <summary>
		/// 转介人姓名
		/// </summary>
		[DataMember]
		public string REFBYNAME
		{
			get{return _refbyname;}
			set{
				if ( _refbyname!= value)
				{
					 _refbyname = value;
					OnPropertyChanged("REFBYNAME");
				}
			}
		}
		/// <summary>
		/// 申请日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> APPDATE
		{
			get{return _appdate;}
			set{
				if ( _appdate!= value)
				{
					 _appdate = value;
					OnPropertyChanged("APPDATE");
				}
			}
		}
		/// <summary>
		/// 转出部门ID
		/// </summary>
		[DataMember]
		public long OUTDEPID
		{
			get{return _outdepid;}
			set{
				if ( _outdepid!= value)
				{
					 _outdepid = value;
					OnPropertyChanged("OUTDEPID");
				}
			}
		}
		/// <summary>
		/// 转出部门名称
		/// </summary>
		[DataMember]
		public string OUTDEPNAME
		{
			get{return _outdepname;}
			set{
				if ( _outdepname!= value)
				{
					 _outdepname = value;
					OnPropertyChanged("OUTDEPNAME");
				}
			}
		}
		/// <summary>
		/// 转出时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> OUTTIME
		{
			get{return _outtime;}
			set{
				if ( _outtime!= value)
				{
					 _outtime = value;
					OnPropertyChanged("OUTTIME");
				}
			}
		}
		/// <summary>
		/// 转入部门ID
		/// </summary>
		[DataMember]
		public long INDEPID
		{
			get{return _indepid;}
			set{
				if ( _indepid!= value)
				{
					 _indepid = value;
					OnPropertyChanged("INDEPID");
				}
			}
		}
		/// <summary>
		/// 转入部门名称
		/// </summary>
		[DataMember]
		public string INDEPNAME
		{
			get{return _indepname;}
			set{
				if ( _indepname!= value)
				{
					 _indepname = value;
					OnPropertyChanged("INDEPNAME");
				}
			}
		}
		/// <summary>
		/// 转入时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> INTIME
		{
			get{return _intime;}
			set{
				if ( _intime!= value)
				{
					 _intime = value;
					OnPropertyChanged("INTIME");
				}
			}
		}
		/// <summary>
		/// 后续业务员记录ID
		/// </summary>
		[DataMember]
		public long SALESMANID
		{
			get{return _salesmanid;}
			set{
				if ( _salesmanid!= value)
				{
					 _salesmanid = value;
					OnPropertyChanged("SALESMANID");
				}
			}
		}
		/// <summary>
		/// 后续业务员
		/// </summary>
		[DataMember]
		public string SALESMAN
		{
			get{return _salesman;}
			set{
				if ( _salesman!= value)
				{
					 _salesman = value;
					OnPropertyChanged("SALESMAN");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string DETAIL
		{
			get{return _detail;}
			set{
				if ( _detail!= value)
				{
					 _detail = value;
					OnPropertyChanged("DETAIL");
				}
			}
		}
		/// <summary>
		/// 状态0已保存、1已提交、3被拒绝、2已转介、4已分配受理,默认为0
		/// </summary>
		[DataMember]
		public int STATUS
		{
			get{return _status;}
			set{
				if ( _status!= value)
				{
					 _status = value;
					OnPropertyChanged("STATUS");
				}
			}
		}
		/// <summary>
		/// 审批人
		/// </summary>
		[DataMember]
		public string AUDITBY
		{
			get{return _auditby;}
			set{
				if ( _auditby!= value)
				{
					 _auditby = value;
					OnPropertyChanged("AUDITBY");
				}
			}
		}
		/// <summary>
		/// 审批时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> AUDITTIME
		{
			get{return _audittime;}
			set{
				if ( _audittime!= value)
				{
					 _audittime = value;
					OnPropertyChanged("AUDITTIME");
				}
			}
		}
		/// <summary>
		/// 退回状态0未退回，1退回，默认为0
		/// </summary>
		[DataMember]
		public int BACKSTATUS
		{
			get{return _backstatus;}
			set{
				if ( _backstatus!= value)
				{
					 _backstatus = value;
					OnPropertyChanged("BACKSTATUS");
				}
			}
		}
		/// <summary>
		/// 预留字段1
		/// </summary>
		[DataMember]
		public int SPAREFIELD1
		{
			get{return _sparefield1;}
			set{
				if ( _sparefield1!= value)
				{
					 _sparefield1 = value;
					OnPropertyChanged("SPAREFIELD1");
				}
			}
		}
		/// <summary>
		/// 预留字段2
		/// </summary>
		[DataMember]
		public string SPAREFIELD2
		{
			get{return _sparefield2;}
			set{
				if ( _sparefield2!= value)
				{
					 _sparefield2 = value;
					OnPropertyChanged("SPAREFIELD2");
				}
			}
		}
		/// <summary>
		/// 预留字段3
		/// </summary>
		[DataMember]
		public string SPAREFIELD3
		{
			get{return _sparefield3;}
			set{
				if ( _sparefield3!= value)
				{
					 _sparefield3 = value;
					OnPropertyChanged("SPAREFIELD3");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

